/*
 * @Author: your name
 * @Date: 2021-08-28 17:27:50
 * @LastEditTime: 2021-08-28 17:28:19
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-admin-template\src\store\modules\permission.js
 */
/**
 * 将动态路由表和静态路由表进行合并
 */

// 导入静态路由表
import { constantRoutes } from '@/router/index'

export default {
  namespaced: true, // 开启命名空间
  state: () => ({
    routes: constantRoutes // 最终合并生成的路由表(动态路由表和静态路由表)
  }),
  mutations: {
    // 对 routes 进行赋值(将动态路由再次赋值给 routes)
    setRoutes(state, asyncRoutes) {
      // 将动态路由表和静态路由表进行合并
      state.routes = [...constantRoutes, ...asyncRoutes]
    }
  }
}
